package homework.exp05;

import java.io.File;
import java.io.FileInputStream;
import java.util.Scanner;

public class F4 {
    static Scanner cin = null;

    static {
        try {
            cin = new Scanner(new FileInputStream(new File("F.in")));
        } catch (Exception e) {
            cin = new Scanner(System.in);
        }
    }


    public static void main(String[] args) {
        while (cin.hasNext()) {
            String sa = cin.next();
            String sb = new StringBuilder(sa).reverse().toString();
            int[][] c = lcs(sa.toCharArray(), sb.toCharArray());
            int best = 0;
            for (int i = 0; i < c.length; i++) {
                for (int j = 0; j < c[i].length; j++) {
                    best = Math.max(best, c[i][j]);
                }
            }
            System.out.println(best);
        }
    }

    public static int[][] lcs(char[] X, char[] Y) {
        /* 构造二维数组c[][]记录X[i]和Y[j]的LCS长度 (i,j)是前缀
         * c[i][j]=0; 当 i = j = 0;
         * c[i][j]=c[i-1][j-1]+1; 当 i = j > 0; Xi == Y[i]
         * c[i][j]=max(c[i-1][j],c[i][j+1]); 当 i = j > 0; Xi != Y[i]
         * 需要计算 m*n 个子问题的长度 即 任意c[i][j]的长度
         * -- 填表过程
         */
        int[][] c = new int[X.length + 1][Y.length + 1];

        // 动态规划计算所有子问题
        for (int i = 1; i <= X.length; i++) {
            for (int j = 1; j <= Y.length; j++) {
                if (X[i - 1] == Y[j - 1]) {
                    c[i][j] = c[i - 1][j - 1] + 1;
                } else if (c[i - 1][j] >= c[i][j - 1]) {
                    c[i][j] = c[i - 1][j];
                } else {
                    c[i][j] = c[i][j - 1];
                }
            }
        }
        return c;
    }
}
